package com.cxd.web.frontend;

import com.cxd.entity.EbNews;
import com.cxd.service.IEbNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/f-news")
public class EbNewsController {
    @Autowired //spring 注入 给newsService赋值
    private IEbNewsService iEbNewsService;
    @RequestMapping("/detail" )
    public String detail(HttpSession session, Model model , Integer enId) {
        Object userNow = session.getAttribute("lgnUser");
        if (userNow == null){
            return "redirect:/f-login/to_login";
        }
        model.addAttribute("userNow",userNow);
        System.out.println("enId===>" + enId);

        EbNews ebNews = iEbNewsService.selectOne(enId);
        System.out.println(ebNews);

        model.addAttribute("ebNews", ebNews);
        return "news-view";
    }
}
